package com.xiaoyao.novel.action.page;

import java.util.List;

import org.apache.log4j.Logger;

import com.xiaoyao.novel.pojo.FriendLink;
import com.xiaoyao.novel.service.FriendLinkService;

public class FriendLinkAction extends BaseAction {
	private static Logger logger = Logger.getLogger(FriendLinkAction.class);
	private static final long serialVersionUID = 1L;
	static FriendLinkService friendLinkService = new FriendLinkService();
	FriendLink friendLink;

	@Override
	public String execute() throws Exception {
		List<FriendLink> list = friendLinkService.getAll();
		request.setAttribute("list", list);
		return SUCCESS;
	}

	public String updateLink() throws Exception {
		friendLinkService.update(friendLink);
		return execute();
	}

	public String addLink() throws Exception {
		friendLinkService.insert(friendLink);
		return execute();
	}

	public String delLink() throws Exception {
		friendLinkService.delete(friendLink.linkId);
		return execute();
	}

	// ////////////////////////
	public String toAddLink() throws Exception {
		return "toAddLink";
	}

	public String toUpdateLink() throws Exception {
		friendLink = friendLinkService.getById(friendLink.linkId);
		request.setAttribute("friendLink", friendLink);
		return "toUpdateLink";
	}

	// ////////////////////////
	public FriendLink getFriendLink() {
		return friendLink;
	}

	public void setFriendLink(FriendLink friendLink) {
		this.friendLink = friendLink;
	}

	// ////////////////////////////

}
